<template>
	<view class="control">
		<!-- <view class="con-1">
			<nav-bar title="审批管理" color="white" bg="rgba(0,0,0,0)"></nav-bar>
			<view class="bg">
				<image mode="widthFix" src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/5d1ccc3b7ac6cc185130c88a8ac2e90b1eeba707.png"/>
			</view>
		</view> -->
		<view class="con-1">
			<nav-bar title="审批管理" color="white" bg="rgba(0,0,0,0)"></nav-bar>
			<view class="bg">
				<view class="address">
					<view class="flex-space-between">
						<view class="flex-align">
							<van-image v-if="itemChooselist.venue_thumb != ''" width="74rpx" height="74rpx" radius="2"
								style="margin-right: 10rpx;" :src="itemChooselist.venue_thumb" />
							<van-image v-else width="74rpx" height="74rpx" radius="10rpx" fit="cover" style="margin-right: 10rpx;" src="https://img.yzcdn.cn/vant/cat.jpeg" />
							<view>
								<view class="address-name">{{itemChooselist.venue_name}}</view>
								<view class="address-desc">地址:{{itemChooselist.address}}</view>
							</view>
						</view>
						<view class="exchange flex-center flex-column " @click="show = true">
							<van-icon name="exchange" size="16" />
							切换
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="con-2">
			<view class="con-3">
				<view class="item" @click="openList(0)">
					<view class="num" style="color: rgb(255,65,5);">{{count.wait}}</view>
					<view>待审批</view>
				</view>
				<view class="item" @click="openList(1)">
					<view class="num">{{count.pass}}</view>
					<view>已通过</view>
				</view>
				<view class="item" @click="openList(2)">
					<view class="num">{{count.refuse}}</view>
					<view>未通过</view>
				</view>
				<!-- <view class="tag" @click="openList(0)">
					<text>全部</text>
					<van-icon name="arrow" />
				</view> -->
			</view>
			<view class="con-4 flex-align">
				待审核记录
			</view>
			<view class="list" v-if="Auditlist.length">
				<view class="item" v-for="(item,index) in Auditlist" :key="index" @click="openDetail(item,index)">
					<view class="status pa"
						:style="{ backgroundImage: `url(${icon1})` }">
					</view>
					<view>
						<view class="item-title">{{item.model}}</view>
						<view class="detail1">
							{{item.content}}
						</view>
					</view>
					<view class="detail" style="font-size: 22rpx;">
						{{item.user_name?item.user_name:''}}  {{item.phone?item.phone:''}}
					</view>
					<view class="flex-space-between">
						<view class="flex">
							<image mode="aspectFit"
								src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/f1b17f37fac7f668a8c3fcb692915b2e59a0236d.png" />
							<text class="time">{{item.apply_user_name}}</text>
						</view>
						<view class="time ti">
							{{item.create_at}}
						</view>
					</view>
				</view>
			</view>
			<u-empty v-else mode="" text="数据为空"
				icon="https://sass-test.doit10019.com/upload/202501/08114139-33838600519097990.jpg?attname=coupon.jpg" />
		</view>
		<van-popup closeable :show="show" round position="bottom" @close="show = false">
			<view class="good-box">
				<view class="title">
					切换场馆
				</view>
				<view class="good-list">
					<view class="good-item" v-for="(item,index) in venuelist" :key="index" @click="onChangelist(item)">
						<view class="flex-align">
							<van-image width="124rpx" height="124rpx" radius="10rpx" fit="cover"
								v-if="item.venue_thumb != ''" :src="item.venue_thumb" />
							<van-image v-else width="124rpx" height="124rpx" radius="10rpx" fit="cover"
								src="https://img.yzcdn.cn/vant/cat.jpeg" />
							<view class="info">
								<view class="name">{{item.venue_name}}</view>
								<view class="flex-align" v-if="item.project_list != ''">
									<view class="tag" v-if="item.project_list[0].name != ''">
										{{item.project_list[0].name}}
									</view>
									<view class="tag" v-if="item.project_list[1].name != '' && item.project_list[1]">
										{{item.project_list[1].name}}
									</view>
									<view class="tag" v-if="item.project_list[2].name != ''&& item.project_list[2]">
										{{item.project_list[2].name}}
									</view>
								</view>
								<view class="address">{{item.address}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</van-popup>
	</view>
</template>

<script>
	const personal = require("@/api/personal/index.js");
	export default {
		data() {
			return {
				count: {
					pass: 0,
					refuse: 0,
					wait: 0,
				},
				Auditlist: [],
				show: false,
				itemChoose: {}, // 场馆数据
				itemChooselist: {}, // 场馆数据
				venuelist: [], //场馆列表
				icon1: 'https://sass-test.doit10019.com/upload/202502/19131832-08961913387416362.png?attname=daishenhe.png'
			}
		},
		onLoad() {
			var data = uni.getStorageSync("wqzdy");
			var items = JSON.parse(data)
			this.venuelist = items
			this.itemChooselist = this.venuelist[0]
			
		},
		onShow() {
			this.countPoint()
			this.waitAudit()
		},
		methods: {
			onChangelist(item) {
				this.itemChoose = item
				this.itemChooselist = this.itemChoose
				this.show = false
				this.countPoint()
				this.waitAudit()
			},
			async countPoint() {
				let that = this;
				let params = {
					venue_id: this.itemChooselist.id,
				};
				let res = await personal.countPoint(params);
				if (res.code == 1) {
					this.count = res.data
				}
			},
			async waitAudit() {
				let that = this;
				let params = {
					venue_id: this.itemChooselist.id,
				};
				let res = await personal.waitAudit(params);
				if (res.code == 1) {
					this.Auditlist = res.data
				}
			},
			openList(index) {
				uni.navigateTo({
					url: `/page_admin/approval-admin/approval-list?state=${index}` + "&venue_id=" + this
						.itemChooselist.id
				})
			},
			openDetail(item, index) {
				uni.navigateTo({
					url: `/page_admin/approval-admin/approval-process?id=${item.id}` + "&venue_id=" + this
						.itemChooselist.id + "&model=" + item.model
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.control {
		background-color: rgb(243, 243, 243);
		height: 100vh;
		display: flex;
		flex-direction: column;

		.con-1 {
			width: 100%;
			position: relative;

			/deep/ .nav-bar {
				position: fixed;
				z-index: 999;
			}
		}

		.bg {
			width: 100%;
			height: 300rpx;
			background-image: url("https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/5d1ccc3b7ac6cc185130c88a8ac2e90b1eeba707.png");
			background-size: 100%;
			background-position: 50% 80%;
			position: fixed;
			z-index: 9;

			.address {
				color: #fff;
				padding-top: 190rpx;
				padding-right: 30rpx;
				padding-left: 30rpx;
				height: 150rpx;

				&-name {
					font-size: 34rpx;
					font-weight: 700;
					line-height: 34rpx;
				}

				&-desc {
					margin-top: 18rpx;
					font-size: 22rpx;
					line-height: 22rpx;
				}

				.exchange {
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
					background-color: rgba(0, 0, 0, 0.2);
					color: rgb(234, 248, 248);
					font-size: 24rpx;
				}
			}
		}

		.con-2 {
			padding: 0 30rpx;
			flex: 1;
			height: 0;
			display: flex;
			flex-direction: column;
			margin-top: 400rpx;

			.con-3 {
				padding: 30rpx 40rpx 35rpx 40rpx;
				background-color: rgb(255, 255, 255);
				box-shadow: 0px 0px 13.32rpx 4.68rpx rgba(0, 0, 0, 0.05);
				border-radius: 10rpx;
				display: flex;
				margin-top: -75rpx;
				position: relative;
				justify-content: space-around;

				.tag {
					position: absolute;
					color: rgb(110, 104, 247);
					font-size: 22rpx;
					font-weight: 500;
					right: 20rpx;
					top: 20rpx;
				}

				.item {
					display: flex;
					flex-direction: column;
					color: rgb(136, 136, 136);
					font-size: 24rpx;
					font-weight: 500;
					align-items: center;

					.num {
						color: rgb(51, 51, 51);
						font-size: 32rpx;
						font-weight: 700;
						margin-bottom: 10rpx;
					}
				}
			}

			.con-4 {
				color: rgb(51, 51, 51);
				font-size: 28rpx;
				font-weight: 700;
				margin-top: 40rpx;

				&:before {
					content: '';
					display: block;
					background-color: rgb(109, 103, 247);
					border-radius: 3rpx;
					width: 7rpx;
					height: 35rpx;
					margin-right: 13rpx;
				}
			}

			.list {
				margin-top: 40rpx;
				flex: 1;
				height: 0;
				overflow: auto;

				.item {
					margin-bottom: 20rpx;
					background-color: rgb(255, 255, 255);
					box-shadow: 0px 2rpx 6.86rpx 0.14rpx rgba(0, 0, 0, 0.1);
					border-radius: 10rpx;
					padding: 29rpx 18rpx 30rpx 30rpx;
					height: 280rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					position: relative;
					
					.status {
						top: 30rpx;
						right: 30rpx;
						width: 127rpx;
						height: 100rpx;
						background-position: left top;
						background-repeat: no-repeat;
						background-size: 100% 100%;
					}

					.item-title {
						color: rgb(51, 51, 51);
						font-size: 28rpx;
						font-weight: 700;
						margin-bottom: 24rpx;
					}

					.detail {
						line-height: 34rpx;
						color: rgb(102, 102, 102);
						font-size: 26rpx;
						font-weight: 500;
						
					}
					.detail1 {
						line-height: 34rpx;
						color: rgb(102, 102, 102);
						font-size: 26rpx;
						font-weight: 500;
						box-sizing: border-box;
						margin-bottom: 20rpx;
						white-space: normal;
						/* 允许文本换行 */
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						/* 将元素设置为盒模型 */
						-webkit-box-orient: vertical;
						/* 设置盒模型的方向为垂直 */
						-webkit-line-clamp: 2;
						/* 限制文本显示的行数 */
						/* 移除 height: auto; 让 -webkit-line-clamp 控制高度 */
						line-height: 1.5;
						/* 设置合适的行高，确保文本正确换行和显示 */
						/* max-height 可以根据需要调整，但通常不是必需的，因为 -webkit-line-clamp 会控制高度 */
					}

					image {
						width: 18rpx;
						height: 19rpx;
						margin-right: 11rpx;
					}

					.time {
						color: rgb(51, 51, 51);
						font-size: 24rpx;
						font-weight: 500;
					}

					.ti {
						font-weight: 700;
					}
				}
			}
		}

		/deep/ .good-box {
			height: 60vh;
			padding: 0px 30rpx;
			display: flex;
			flex-direction: column;

			.title {
				color: #000;
				font-size: 30rpx;
				font-weight: 700;
				margin-top: 40rpx;
			}

			.van-radio__label {
				line-height: inherit;
			}

			.good-list {
				flex: 1;
				height: 0;
				overflow: auto;

				.good-item {
					margin-top: 30rpx;

					.info {
						margin-left: 25rpx;

						.address {
							color: #fff;
							padding-top: 20rpx;
							padding-right: 30rpx;
							height: 70rpx;

							&-name {
								font-size: 34rpx;
								font-weight: 700;
								line-height: 34rpx;
							}

							&-desc {
								margin-top: 18rpx;
								font-size: 22rpx;
								line-height: 22rpx;
							}

							.exchange {
								width: 100rpx;
								height: 100rpx;
								border-radius: 50%;
								background-color: rgba(0, 0, 0, 0.2);
								color: rgb(234, 248, 248);
								font-size: 24rpx;
							}
						}

						.name {
							color: rgb(51, 51, 51);
							font-size: 30rpx;
							font-weight: 500;
							margin-bottom: 10rpx;
						}


						.tag {
							color: rgb(4, 179, 90);
							font-size: 24rpx;
							font-weight: 500;
							padding: 0px 10rpx;
							margin-right: 20rpx;
							background-color: rgba(4, 179, 90, 0.2);
							border-radius: 4rpx;

							&:nth-of-type(2) {
								color: rgb(236, 70, 246);
								background-color: rgba(236, 70, 246, 0.2);
							}
						}

						.address {
							margin-top: 10rpx;
							color: rgb(136, 136, 136);
							font-size: 22rpx;
						}
					}

				}
			}

			.footer {
				padding: 20rpx 0;
				background-color: rgb(255, 255, 255);

				.btn {
					color: rgb(255, 255, 255);
					font-size: 30rpx;
					font-weight: 700;
					padding: 20rpx 0;
					text-align: center;
					background-image: linear-gradient(0deg, rgb(99, 93, 247) 0%, rgb(165, 173, 246) 100%);
					border-radius: 60rpx;
				}
			}
		}
	}
</style>